package com.ytf.core.web.pojo.converter;

import com.ytf.core.web.pojo.dto.PermissionDto;
import com.ytf.core.web.pojo.model.Permission;
import com.ytf.core.web.pojo.vo.PermissionVo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

/**
 * @author YTF
 * @className PermissionConverter
 * @date 2025/5/21 16:25
 * @description 权限实体类转换器
 */
@Mapper(componentModel = "spring")
public interface PermissionConverter {

    PermissionConverter INSTANCE = Mappers.getMapper(PermissionConverter.class);

    @Mapping(target = "id", ignore = true)  // DTO转Entity时忽略id
    @Mapping(target = "createTime", ignore = true) // 创建时间由数据库自动生成
    Permission permissionDtoToPermission(PermissionDto dto);

    PermissionVo permissionToPermissionVo(Permission permission);
}
